<?php
abstract class MVC_Model_Base {

    /**
     * @var Container_Interface
     */
    private $_objContainer = null;


    public function __construct(Container_Interface $objContainer) {
        $this->_objContainer = $objContainer;
    }


    /**
     * @return Config_Interface
     */
    protected function getConfig () {
        return $this->_objContainer->get('Config');
    }


    /**
     * @param string $strModelName
     * @return Model_Base
     */
    protected function getModel ($strModelName) {
        return $this->_objContainer
                    ->get('MVC_ModelLoader')
                    ->getModel($strModelName);
    }


    /**
     * @param string $strDbName
     * @param string $strCharset
     * @return DbSimple_Generic_Database
     */
    protected function getDb($strDbName, $strCharset = 'utf8') {
        return $this->_objContainer
                    ->get('DB_Manager')
                    ->getDb($strDbName, $strCharset);
    }


    /**
     * @param string $strDbName
     * @param string $strTableName
     * @param string $strId
     * @param string $strCharset
     * @return DB_Reader
     */
    protected function getDbReader ($strDbName, $strTableName, $strId = 'id', $strCharset = 'utf8') {
        return $this->_objContainer
                    ->get('DB_Manager')
                    ->getDbReader($strDbName, $strTableName, $strId, $strCharset);
    }


    /**
     * @param string $strDbName
     * @param string $strTableName
     * @param string $strId
     * @param string $strCharset
     * @return DB_Curd
     */
    protected function getDbCurd ($strDbName, $strTableName, $strId = 'id', $strCharset = 'utf8') {
        return $this->_objContainer
                    ->get('DB_Manager')
                    ->getDbCurd($strDbName, $strTableName, $strId, $strCharset);
    }
}